#include "diff.h"

extern PARAMETERS qw;
extern TRATATA zz;
extern FILE *fp;

float TBifCalc::f(float par)
{
 float uprb[4],vprb[4],uprc[4],vprc[4],s,f1;
 char str[80]=" F=%f\n",str1[80];
 register int i;

 qw.pr[1] = par;
 if (par != 1000) prm();
 sr();
 fprintf(fp,"mmet=%d\n",qw.mmet);
 if (qw.nz>0) sob();
 otper( par,uprb,vprb,uprc,vprc);
 if (zz.iw==1)
 {
  if (qw.iss!=1)
  {
   for (s=0,i=0;i<zz.P;i++) s+=(uprc[i]-uprb[i])*(uprc[i]-uprb[i]);
   for (i=0;i<zz.Q;i++) s+=(vprc[i]-vprb[i])*(vprc[i]-vprb[i]);
   f1=sqrt((double)s);
  }
  else
  {
   if (zz.Q==1) f1=vprc[0]-vprb[0];
   else f1=uprc[0]-uprb[0];
  }
 }
 else f1=10000.;
 sprintf(str,"F=%5.12f",f1);
 Memo1->Lines->Add(str);
// Memo1->Lines->Add("");
 fprintf(fp,str,f1);
 return f1;
}